﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyClassTeacher
{
    static class Encoder
    {
        public static Bitmap GetCode(string message, int pixel)
        {
            QRCoder.QRCodeGenerator codeGenerator = new QRCoder.QRCodeGenerator();
            QRCoder.QRCodeData codeData = codeGenerator.CreateQrCode(message, QRCoder.QRCodeGenerator.ECCLevel.M);
            QRCoder.QRCode code = new QRCoder.QRCode(codeData);
            Bitmap bmp = code.GetGraphic(pixel);
            return bmp;
        }
        public static Bitmap GetCode(string message,int version,int pixel,string icon_path,int icon_size,int icon_border,bool white_edge    )
        {
            QRCoder.QRCodeGenerator codeGenerator = new QRCoder.QRCodeGenerator();
            QRCoder.QRCodeData codeData = codeGenerator.CreateQrCode(message, QRCoder.QRCodeGenerator.ECCLevel.M, true, true, QRCoder.QRCodeGenerator.EciMode.Utf8, version);
            QRCoder.QRCode code = new QRCoder.QRCode(codeData);
            Bitmap icon = new Bitmap(icon_path);
            Bitmap bmp = code.GetGraphic(pixel, Color.Black, Color.White, icon, icon_size, icon_border, white_edge);
            return bmp;
        }
    }
}
